<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<#import "/common/page.ftl" as p>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${this[0].getText("project_name")}</title>
<link type="text/css" href="${base}/static/css/style.css" rel="stylesheet" rev="stylesheet" />
<link rel="stylesheet" type="text/css" href="${base}/static/js/validate/css/screen.css" />


<script type="text/javascript" src="${base}/static/js/jquery.js"></script>
<script type="text/javascript" src="${base}/static/js/calendar/WdatePicker.js"></script>
<script type="text/javascript" src="${base}/static/js/validate/validate.js"></script>
<script type="text/javascript" src="${base}/static/js/validate/cmxforms.js"></script>
</head>
<body>

<div class="main_content">

<br/>
<h2>新增用户</h2>
<#if errorMessage??><font color="red">${this[0].getText(errorMessage)}</font></#if>
<form id="form1" action='${base}/user/update' method='post'>
	<input type="hidden" value="${user.id}" name="user.id" />
    <table width="100%" cellspacing="0" class="datalist" style="width:50%">
    	<tr>
			<th width='20%'>用户名：</th>
    		<td width='60%'>${user.name}</th>
    	</tr>
		<tr>
			<th>角色：</th>
    		<td><#list roles as role><input type="radio" id="roleIds" name="roleIds" value="${role.id}" <#list user.roles as r><#if (r.id == role.id) >checked</#if></#list>/>${role.description!}&nbsp;</#list></th>
    	</tr>	
		<tr>
			<th>原密码：</th>
    		<td><input type="password" id= "oldpassword" name="oldpassword" /></th>
    	</tr>	   	
    	<tr>
			<th>新密码：</th>
    		<td><input type="password" id="password" name="user.password"/></th>
    	</tr>
		<tr>
			<th>重复新密码：</th>
    		<td><input type="password" id="confirm_password" name="confirm_password"/></th>
    	</tr>
    </table>
    <input type="submit" value="提交"/>
</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$("#form1").validate({
		rules: {     
			oldpassword : {
				required: true
			},
			roleIds: {
				required: true
			},
			"user.password": {
				minlength: 6
			},
			confirm_password: {
				equalTo: "#password"
			}
       },
	   
	   messages:{
	   	 oldpassword : {
				required: "请输入原密码"
			},
		 roleIds: {
			    required: "请选择用户角色"
			},
		"user.password": {
				minlength:"密码最少为6位"
			},
		 confirm_password: {
				equalTo:  "两次密码输入不一致"
			}
		}    
	});		
});

</script>
</body>
</html>
